package pers.cj.pdos.mapper;

import org.apache.ibatis.annotations.Param;
import pers.cj.pdos.entity.Sale;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import pers.cj.pdos.vo.InGoodsVo;
import pers.cj.pdos.vo.SaleOrderVo;
import pers.cj.pdos.vo.SaleVo;

import java.util.Date;
import java.util.List;

/**
 * <p>
 * 当销售单产生后，订单会进入待出库状态，需要仓库管理员进行出库操作 Mapper 接口
 * </p>
 *
 * @author chenj
 * @since 2019-11-04
 */
public interface SaleMapper extends BaseMapper<Sale> {
    List<SaleVo> listVo(@Param("companyId") String companyId,
                        @Param("page") Integer page,
                        @Param("limit") Integer limit,
                        @Param("close") Boolean close,
                        @Param("search") String search,
                        @Param("no") String no,
                        @Param("goodsName") String goodsName,
                        @Param("remark") String remark,
                        @Param("storeId") String storeId,
                        @Param("houseId") String houseId,
                        @Param("settAccountId") String settAccountId,
                        @Param("custom") String custom,
                        @Param("deliveryDate1") Date deliveryDate1,
                        @Param("deliveryDate2")Date deliveryDate2,
                        @Param("makeTime1") Date makeTime1,
                        @Param("makeTime2")Date makeTime2,
                        @Param("userStoreId") String userStoreId,
                        @Param("userId") String userId,
                        @Param("date1")Date date1,
                        @Param("date2")Date date2,
                        @Param("date")Date date,
                        @Param("makeUserId") String makeUserId,
                        @Param("customId") String customId,
                        @Param("status") Integer status);

    Long count(@Param("companyId") String companyId,
               @Param("close") Boolean close,
               @Param("search") String search,
               @Param("no") String no,
               @Param("goodsName") String goodsName,
               @Param("remark") String remark,
               @Param("storeId") String storeId,
               @Param("houseId") String houseId,
               @Param("settAccountId") String settAccountId,
               @Param("custom") String custom,
               @Param("deliveryDate1") Date deliveryDate1,
               @Param("deliveryDate2")Date deliveryDate2,
               @Param("makeTime1") Date makeTime1,
               @Param("makeTime2")Date makeTime2,
               @Param("userStoreId") String userStoreId,
               @Param("userId") String userId,
               @Param("date1")Date date1,
               @Param("date2")Date date2,
               @Param("date")Date date,
               @Param("makeUserId") String makeUserId,
               @Param("customId") String customId,
               @Param("status") Integer status);

    List<SaleVo> listVoForTicket(@Param("companyId") String companyId,
                                 @Param("page") Integer page,
                                 @Param("limit") Integer limit,
                                 @Param("ticket") Integer ticket,
                                 @Param("search") String search,
                                 @Param("no") String no,
                                 @Param("goodsName") String goodsName,
                                 @Param("remark") String remark,
                                 @Param("storeId") String storeId,
                                 @Param("houseId") String houseId,
                                 @Param("settAccountId") String settAccountId,
                                 @Param("custom") String custom,
                                 @Param("deliveryDate1") Date deliveryDate1,
                                 @Param("deliveryDate2")Date deliveryDate2,
                                 @Param("makeTime1") Date makeTime1,
                                 @Param("makeTime2")Date makeTime2,
                                 @Param("userStoreId") String userStoreId,
                                 @Param("userId") String userId,
                                 @Param("date1")Date date1,
                                 @Param("date2")Date date2,
                                 @Param("makeUserId") String makeUserId);

    Long countForTicket(@Param("companyId") String companyId,
                        @Param("ticket") Integer ticket,
                        @Param("search") String search,
                        @Param("no") String no,
                        @Param("goodsName") String goodsName,
                        @Param("remark") String remark,
                        @Param("storeId") String storeId,
                        @Param("houseId") String houseId,
                        @Param("settAccountId") String settAccountId,
                        @Param("custom") String custom,
                        @Param("deliveryDate1") Date deliveryDate1,
                        @Param("deliveryDate2")Date deliveryDate2,
                        @Param("makeTime1") Date makeTime1,
                        @Param("makeTime2")Date makeTime2,
                        @Param("userStoreId") String userStoreId,
                        @Param("userId") String userId,
                        @Param("date1")Date date1,
                        @Param("date2")Date date2,
                        @Param("makeUserId") String makeUserId);

    SaleVo getVoById(@Param("id")String id);

    List<SaleVo> listVoByIds(@Param("ids")List<String> ids);

    List<SaleVo> listVoForSelect(@Param("companyId") String companyId,
                                 @Param("page") Integer page,
                                 @Param("limit") Integer limit,
                                 @Param("search") String search,
                                 @Param("storeId") String storeId,
                                 @Param("userStoreId") String userStoreId,
                                 @Param("userId") String userId);


    Long countForSelect(@Param("companyId") String companyId,
                        @Param("search") String search,
                        @Param("storeId") String storeId,
                        @Param("userStoreId") String userStoreId,
                        @Param("userId") String userId);

    List<SaleVo> listVoBySaleOrder(@Param("saleOrderId") String saleOrderId);

    SaleVo getLastRetailByUserId(@Param("userId") String userId);

    List<SaleVo> listVoByBorrowOut(@Param("borrowOutId") String borrowOutId);

    Long checkTicket(@Param("ids")List<String> ids);

    void batchTicket(@Param("ids")List<String> ids);
}
